function camA = GetCameraS03Matrix( pos ) 

% the matrix that transforms the 
% camera to be at pos, viewing the origin

% The T part of the matrix is just [pos]

camA = zeros(4,4); % we get a 4x4 matrix operating on homog. coordinates

T = pos(:);

% claim: there should not be a negative here!
dir = -T / norm(T); % direction from point to origin

% R^-1 maps dir to [0 0 1]'

phi = atan2( dir(1), dir(2) );
P1 = [cos(phi) -sin(phi) 0; sin(phi) cos(phi) 0; 0 0 1];
dhat = P1*dir;
alpha = pi/2 - atan2(dir(3),dhat(2));
P2 = [1 0 0; 0 cos(alpha) -sin(alpha); 0 sin(alpha) cos(alpha)];

Rinv = P2*P1;
R = [ Rinv zeros(3,1); zeros(1,3), 1];
TT = [ eye(3,3) T; zeros(1,3) 1];
camA = R * TT; 

% R after TT gives "what is the coordinate of the operated
% upon point in the camera coordinates, where the camera is at T 
% and pointed at the origin

breakhere = 1;